package chapter03;

/**
 * 练习-九层妖塔
 */
public class Java06_FlowControl_Test {
    public static void main(String[] args) {
        System.out.println("方法一");
        // 打印第一层循环
        for (int i = 0; i < 1; i++) {
            System.out.print("*");
        }
        System.out.println("");

        // 打印第二层循环
        /*
            println方法打印字符串后会自动添加换行符
            print方法打印字符串后不换行
         */
        for (int i = 0; i < 3; i++) {
            System.out.print("*");
        }
        System.out.println("");
        // 打印第三层循环
        for (int i = 0; i < 5; i++) {
            System.out.print("*");
        }
        System.out.println("");
        // 打印第四层循环
        for (int i = 0; i < 7; i++) {
            System.out.print("*");
        }
        System.out.println("");

        System.out.println("-----------");

        System.out.println("方法二");

        for (int j = 0; j < 9; j++) {
            for (int i = 0; i < j*2+1; i++) {
                System.out.print("*");
            }
            System.out.println("");
        }

        System.out.println("-----------");

        System.out.println("方法三");
        int level = 9;
        for (int i = 0; i < level; i++) {
            for (int j = 0; j < (level-1) - i; j++) {
                System.out.print(" ");
            }
            for (int j = 0; j < i*2+1; j++) {
                System.out.print("*");
            }
            System.out.println("");
        }

    }


}
